<html>
<head>
<title>欢迎光临学习资料查询系统</title>
<link href="css/ponts_common.css" rel="stylesheet" type="text/css"/> 
<link href="css/bj_common.css" rel="stylesheet" type="text/css"/> 
<link href="css/bj_others.css" rel="stylesheet" type="text/css"/> 

<meta http-equiv="Content-Type" content="text/html"; charset="utf-8">

</head>
<body onLoad="MM_preloadImages('images/background2.jpg')">
<div class="com_1"><img src="images/42.jpg" alt="1"  border="0" align="middle"/></div>
      <div class="com_2">
       <div class="com_2_1">
   		 <span title="首 页" class="com_2_1_2"><a href="index.php"  class="headline">首 页</a></span>
    	 <span title="资料查询" class="com_2_1_2"><a href="quest.php"  class="headline">资料查询</a></span>
   		 <span title="资料共享" class="com_2_1_1"><a href="Uploaduser.php"  class="headline">资料共享</a></span>
 	     <span title="资料求助" class="com_2_1_1"><a href="seeking.php" class="headline">资料求助</a></span>
  	     <span title="个人中心" class="com_2_1_1"><a href="memcenter.php" class="headline">个人中心</a></span>
        </div>
      </div> 
         
      <div class="com_3">    
              <div class="com_3_1">
                <?php
                session_start();
						  $username=$_SESSION["username"];
						  session_destroy();
 			if ($username<>"")
 			{ 
			 	echo '<table><tr valign=top><td>&nbsp;</td></tr>';
			 	echo '<tr><td  width=74 class=ti align=right>';
			 	echo '你好!</td><td>'.$username;
			 	echo '</td></tr></table>';
 			}
 			else 
 			{
            	echo '<table><tr valign=top>';
            	echo '<td><p class=ti>用户登录&amp;注册</p>';
            	echo '<form action=chklogin.php method=post name=longform>';
				echo '<table><tr valign=top align=center><td width=74>';
				echo '用户名</td>';
				echo '<td width=170>';
				echo '<input name=passname type=text maxlength=20 size=20>';
				echo '</td></tr><tr valign=top align=center><td>';
				echo '密码</td>';
     			echo '<td><input name=password type=password maxlength=18 size=20></td></tr><tr valign=middle align=center>';
				echo '<td colspan=2>   <input name=submit type=submit value=登录 size=2>';
				echo ' &nbsp; &nbsp;&nbsp; <a href=Reg.php class=black>注册</a>';		
				echo '</td></tr></table></form></td></tr></table>';
 			}
				?>
                </div>
            <div class="com_3_2">
				     <div class="quest_1">
                 		<form action="questget.php" method="get">
                        <table>
                   <tr valign="middle">
                   	<td width="100" class="ti">搜索:</td>
                        <td width="300" align="left"><input type="text" maxlength="30" name="questname" size="60"></td>
                       <td width="76" align="left"><input type="submit" name="quest" value="查询">  </td>
                   </tr>
                    <tr>
                       <td></td>
                       <td colspan="3">
			<input type="radio" name="$lm" value="all" checked="" id="all"/>全部
			<input type="radio" name="$lm" value="dz"/>地址
			<input type="radio" name="$lm" value="lj"/>连接
   		    <input type="radio" name="$lm" value="wj"/>文件
                       </td>
                   </tr>
                   </table>
                   </form>
                        </div> 
                        
                        
                                       
<?php
require 'Conn.php';
$i=0;
$pn=1;
$pagesize=10;
$totalsize=0;
$totalpn=0;
$querywords=array();
$questname=mysql_real_escape_string(trim($_GET['questname']));
$querywords['0']=strtok($questname, ' +');
while ($querywords[$i]!== false )
{
	$i++;
	$querywords[$i]=strtok(' +');
}
$lm=mysql_real_escape_string(trim($_GET('lm')));
$pn=CInt($_GET('pn'));	
if ($questname=='')
{
    echo '<script>alert(\'请输入名称！\')</script>';
    exit();
}
Else
{
    $sql="SELECT * FROM resource WHERE filetype='$lm' AND filestate<>2";
    if ($lm="all")
    	$sql="SELECT * FROM resource WHERE filestate<>'2'";
	foreach ($querywords as $i-> $value)
        $sql=$sql." AND filename LIKE '%$value%'";
    $result=mysql_query($sql,$Conn);
    $totalsize=mysql_num_rows($result);
    if ($totalsize==0)
	    echo '<div class=quest_2><div class=view_title>抱歉，没有此资料！</div></div>';
    else
    {
        $totalpn=floor($totalsize/$pagesize);
        if ($totalsize%$pagesize!=0)
            $totalpn=$totalpn+1;
        if ($pn<1||$pn>$totalpn)
            $pn=1;
        $sql=$sql.' LIMIT '.(($pn-1)*$pagesize).' , '.$pagesize;
        mysql_query($sql,$Conn);
        $i=0;
        while ($row=mysql_fetch_array($result)&&$i!=$pagesize)
        {
                $i++;
   				echo '<div class=quest_2><div>';
				if ($row['filestate']==1)
					echo '<span class=yitongguo>已通过</span>';
				else
					echo '<span class=shenhe>审核中</span>';
				echo '<span><a class=view_title1 target="view_window" href=view.php?fileid='.$row['fileid'].'>&nbsp;'.$row['filename'].'</a></span>';
				echo '</div><div class=questget_1>';
				echo'<span class=view_tag>课程代号：'.htmlentities($row['subject']).'&nbsp;&nbsp;贡献者：'.htmlentities($row['uploaduser']).'&nbsp;&nbsp;贡献时间：'.htmlentities($row['uploadtime']).'&nbsp;&nbsp;浏览：'.$row['viewtimes'].'次&nbsp;&nbsp;</span>"';
				echo '</div><hr /></div>';
        }    
    }
}
echo '<div class=questget_2>';
for ($i=1;$i<=$totalpn;$i++)
    echo '<a class=ti href=questget.php?$pn='.$i.'&questname='.$questname.'&subject='.$subject.'&lm='.$lm.' class=black>'.$i.'&nbsp;</a>';
echo '</div>';
?>                       
            </div>
      </div>
      <div class="com_4">
       Copyright@2012 学习资料共享查询系统 v1.0 版权所有 
      </div>
</body>
</html>